<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>读者信息</title>
		<!-- Bootstrap core CSS -->
		<link href="asserts/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/css/bootstrap.css}" rel="stylesheet">

		<!-- Custom styles for this template -->
		<link href="asserts/css/dashboard.css" th:href="@{/asserts/css/dashboard.css}" rel="stylesheet">		
		<script type="text/javascript" src="asserts/js/jquery-3.2.1.slim.min.js" th:src="@{/webjars/jquery/jquery.js}"></script>
		<script type="text/javascript" src="asserts/js/bootstrap.min.js" th:src="@{/webjars/bootstrap/js/bootstrap.js}"></script>
	
	</head>

	<body>
		<!--引入抽取的topbar-->
		<!--模板名：会使用thymeleaf的前后缀配置规则进行解析-->
		<div th:replace="commons/bar::topbar"></div>

		<div class="container-fluid">
			<div class="row">
				<!--引入侧边栏-->
				<div th:replace="commons/bar::#sidebar(activeUri='readers')"></div>

				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
					<h3 class="text-center text-primary">读者信息列表</h3> 
<!-- 					<h2><a class="btn btn-sm btn-success" href="reader" th:href="@{/reader}">增加读者</a></h2> -->
					 
					<div class="table-responsive">
						<table class="table table-striped table-sm">
							<thead>
								<tr>
									<th>编号#</th>
									<th>姓 名</th>
									<th>借书证号</th>
									<th>性 别</th>
									<th>邮 箱</th>
									<th>联系电话</th>
									<th>状 态</th>
									<th>最大可借阅（本）</th>
									<th>已借（本）</th>
<!-- 									<th>操作</th> -->
								</tr>
							</thead>
							<tbody>
								<tr th:each="reader:${readers}">
									<td th:text="${reader.id}"></td>
									<td>[[${reader.name}]]</td>
									<td>[[${reader.readerID}]]</td>
									<td th:text="${reader.gender}"></td>
									<td th:text="${reader.Email}"></td>
									<td th:text="${reader.phoneNumber}"></td>
									<td th:text="${reader.state}"></td>
									<td th:text="${reader.checkoutAmount}"></td>
									<td >
									    <a th:href="${'/bookborrow/byreader/'+reader.id}" th:text="${reader.borrowedBookCnt}">
									       0
									    </a>
									</td>
<!-- 									<td> -->
<!-- 										<a class="btn btn-sm btn-primary" th:href="@{/reader/}+${reader.id}">编辑</a> -->
<!-- 										<button th:attr="del_uri=@{/reader/}+${reader.id}" class="btn btn-sm btn-danger deleteBtn">注销</button> -->
<!-- 									</td> -->
								</tr>
							</tbody>
						</table>
					</div>
				</main>
				<form id="deleteReaderForm"  method="post">
					<input type="hidden" name="_method" value="delete"/>
				</form>
			</div>
		</div>

		<!-- Bootstrap core JavaScript
    ================================================== -->
		<!-- Placed at the end of the document so the pages load faster -->

		<script>
			$(".deleteBtn").click(function(){
			    //删除当前员工的
			    $("#deleteReaderForm").attr("action",$(this).attr("del_uri")).submit();
			    return false;
            });
		</script>
	</body>
</html>